{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-09-19T04:04:12.077693Z",
     "start_time": "2024-09-19T04:04:11.879582Z"
    }
   },
   "source": [
    "import requests\n",
    "import json\n",
    "\n",
    "\n",
    "host = 'http://shop-xo.hctestedu.com'\n",
    "\n",
    "pub_pararms = {\n",
    "    \"application\": \"app\",\n",
    "    \"application_client_type\": \"pc\",\n",
    "    \"s\": \"api/user/login\"\n",
    "}\n",
    "\n",
    "data_body = {\n",
    "    \"accounts\": \"felix_test\",\n",
    "    \"pwd\": \"11081103\",\n",
    "    \"type\": \"username\"\n",
    "}\n",
    "\n",
    "header = {\n",
    "    \"Content-Type\": \"Application/json\"\n",
    "}\n",
    "data_body_link = 'accounts=felix_test&pwd=11081103&type=username'\n",
    "\n",
    "re = requests.request(\"POST\",url=host,headers=header,params=pub_pararms,data=json.dumps(data_body))\n",
    "\n",
    "print(re)\n",
    "print(re.url)\n",
    "print(re.request.url)\n",
    "print(\"请求头:\",re.request.headers)\n",
    "print(\"响应头:\",re.headers)\n",
    "# print(re.request.body)\n",
    "print(re.json())\n"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Response [200]>\n",
      "http://shop-xo.hctestedu.com/?application=app&application_client_type=pc&s=api%2Fuser%2Flogin\n",
      "http://shop-xo.hctestedu.com/?application=app&application_client_type=pc&s=api%2Fuser%2Flogin\n",
      "请求头: {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'Application/json', 'Content-Length': '65'}\n",
      "响应头: {'Server': 'nginx', 'Date': 'Thu, 19 Sep 2024 04:04:30 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Set-Cookie': 'PHPSESSID=jmhs4ku4vedfn7m555rkqu4l8t; path=/; HttpOnly', 'Expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'Cache-Control': 'no-store, no-cache, must-revalidate', 'Pragma': 'no-cache'}\n",
      "{'msg': '登录成功', 'code': 0, 'data': {'id': '19631', 'username': 'felix_test', 'nickname': '', 'mobile': '', 'email': '', 'avatar': 'http://shop-xo.hctestedu.com/static/index/default/images/default-user-avatar.jpg', 'alipay_openid': '', 'weixin_openid': '', 'weixin_unionid': '', 'weixin_web_openid': '', 'baidu_openid': '', 'toutiao_openid': '', 'qq_openid': '', 'qq_unionid': '', 'integral': '0', 'locking_integral': '0', 'referrer': '0', 'add_time': '1723305846', 'add_time_text': '2024-08-11 00:04:06', 'mobile_security': '', 'email_security': '', 'user_name_view': 'felix_test', 'is_mandatory_bind_mobile': 0, 'token': 'f7b7baaeab669925e45cb9686c5edcbb'}}\n"
     ]
    }
   ],
   "execution_count": 4
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "f974eba50d2ff3ef"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
